<template>
    <el-main>
        <el-main class="ep-body">
            <epl-top-bar :datas="{formData:form}" showPerson psTagType="PERSON_PENSION_QUERY"
                         personType="PERSON_ALL_EXACT">
            </epl-top-bar>
            <epl-userMessage dataType="person" idCount="1">
            </epl-userMessage>
            <el-card class="ep-card">
                <ep-title>资格认证信息</ep-title>
                <el-form :model="form" :rules="rules">
                    <el-row :gutter="10">
                        <ep-select colspan="8" label="离退休类别" placeholder="请选择离退休类别" name="aic161" codetype="AIC161" :property="form.aic161"
                                   p="R"  :datas="{formData:form}"></ep-select>
                        <ep-date colspan="8" label="离退休日期" format="yyyyMM" placeholder="请选择离退休日期" value-format="yyyyMM" name="aic162" :property="form.aic162"
                                 p="R"  :datas="{formData:form}"></ep-date>
                        <ep-dateYMD
                            type="YY-MM"
                            colspan="8"
                            isChange
                            label="无基数缴费年限"
                            name="bic100"
                            :property="form.bic100"
                            p="R"
                            :datas="{formData: form}"
                        ></ep-dateYMD>
                    </el-row>
                    <el-row :gutter="10">

                        <ep-dateYMD
                            type="YY-MM"
                            colspan="8"
                            label="视同缴费年限"
                            name="aae200"
                            :property="form.aae200"
                            p="R"
                            :datas="{formData: form}"
                        ></ep-dateYMD>
                        <ep-dateYMD
                            type="YY-MM"
                            colspan="8"
                            label="实际缴费年限"
                            name="aae201"
                            :property="form.aae201"
                            p="R"
                            :datas="{formData: form}"
                        ></ep-dateYMD>
                        <ep-dateYMD
                            type="YY-MM"
                            colspan="8"
                            isChange
                            label="累计缴费年限"
                            name="totalyears"
                            :property="form.totalyears"
                            p="D"
                            :datas="{formData: form}"
                        ></ep-dateYMD>
                    </el-row>

                    <el-row type="flex" justify="center">
                        <ep-saveButton id="doSave" type="primary" top="30" bottom="20"
                                       :datas="{formData: form,panel:panel}"></ep-saveButton>
                    </el-row>
                </el-form>
            </el-card>
        </el-main>
    </el-main>
</template>
<script type="es6">
    export default {
        data() {
            return {
                show: false,
                form: {
                    aic161:{
                        p:"R",
                        value:'',
                        key:''
                    },
                    aic162:{
                        p:"R",
                        value:''
                    },
                    bic100:{
                        p:"E",
                        value:'0-0'
                    },
                    aae200: {
                        p: "D",
                        value: '0-0'
                    },
                    aae201: {
                        p: "D",
                        value: '0-0',
                    },
                    totalyears: {
                        p: "D",
                        value: '0-0',
                    }
                },
                codeTypes: {
                    AIC161: [],
                },
                rules: {
                    aic161:[{required:true}],
                    aic162:[{required:true}],
                    bic100: [{
                        required: true ,validator: this.$rules.isNumber, trigger: 'blur'
                    }]
                },
                panel: {}
            }
        },
        computed: {
            init_form() {
                return this.$store.getters.init.form;
            },
            doInit: {
                get: function () {
                    if (this.$store.getters.common === null) return [];
                    return this.$store.getters.common.formData;
                },
                set: function (value) {
                    return value;
                }
            },
            doPanel: {
                get: function () {
                    if (this.$store.getters.common === null) return {};
                    return this.$store.getters.common.panel;
                },
                set: function (newValue) {
                    return newValue;
                }
            }
        },
        watch: {
            init_form: {
                handler(value) {
                    this.getInitform(value);
                },
                deep: true
            },
            doInit: {
                handler(value) {
                    this.getInitform(value);
                },
                deep: true
            },
            doPanel: {
                handler(value) {
                    if (value == undefined) return;
                    this.getPanel(value);
                },
                deep: true
            }
        },
        mounted() {
            let param = {
                codeTypes: this.codeTypes,
                form: this.form,
            };
            this.$store.dispatch('SET_INIT', param);
        },
        methods: {
            getPanel(value) {
                this.panel = value;
            },
            handleSizeChange(val) {
                console.log(`每页 ${val} 条`);

            },
            handleCurrentChange(val) {
                console.log(`当前页: ${val}`);
            },
            /**
             * 获取初始
             */
            getInitform(value) {
                if (value === undefined) return
                // console.log('value',value);
                this.form = value;
            },
            handleEdit(id) {
                this.dialogFormVisible = true;
            },
            handleChange(val) {
                console.log(val)
            }
        }
    }
</script>

